package de.schule.barnimgymnasium.autotransporter;

import org.eclipse.swt.graphics.Point;

public class SnapPoint {

	private Point location;
	private int snapLen;

	public SnapPoint(final Point location, final int snapLen) {
		this.location = location;
		this.snapLen = snapLen;
	}

	public Point getLocation() {
		return this.location;
	}

	// public void setLocation(final Point newLocation) {
	// this.location.x = newLocation.x;
	// this.location.y = newLocation.y;
	// }

	public boolean nearby(final GameItem item) {
		final Point p = item.getLocation();
		int height = item.img.getBounds().height;

		return Math.abs(this.location.x - p.x) < this.snapLen
				&& Math.abs(this.location.y - (p.y + height)) < this.snapLen;
	}
}
